<?php
namespace WeChatPay\Request;

use function WeChatPay\FilterParam;
use function WeChatPay\FuncReturn;

/**
 * 查询订单API 微信支付订单号查询
 * 商户可以通过查询订单接口主动查询订单状态，完成下一步的业务逻辑。查询订单状态可通过微信支付订单号或商户订单号两种方式查询
 * Class WeChatPayTradeTransactionIdQueryRequest
 * @package WeChatPay\Request
 */
class WeChatPayTradeTransactionIdQueryRequest extends AbstractBaseRequest
{
    protected $apiUri = "v3/pay/transactions/id/%s";

    /**
     * 请求方式
     * @var string
     */
    public $requestType = 'get';

    /**
     * 必填参数列表
     * @var array
     */
    protected $mustAddParams = ['transaction_id'];

    /**
     * 属性映射方法名称
     * @var array
     */
    protected $propertyMapSetFunction = [
        'transaction_id'    =>  'setTransactionId'
    ];

    /**
     * 微信支付订单号:微信支付系统生成的订单号
     * @var string
     */
    protected $transaction_id = "";

    /**
     * 获取接口请求地址
     * @return string
     */
    public function getApiUri()
    {
        return sprintf($this->apiUri, $this->transaction_id);
    }

    /**
     * 获取配置基础参数列表
     * @return array
     */
    public function getBaseParams(): array {
        return ['mchid'];
    }

    /**
     * 获取微信支付订单号
     * @return string
     */
    public function getTransactionId(): string
    {
        return $this->transaction_id;
    }

    /**
     * 设置微信支付订单号
     * @param string $transaction_id
     */
    public function setTransactionId(string $transaction_id): void
    {
        $this->addPathParams('transaction_id');
        $this->transaction_id = $transaction_id;
    }
}